/*    */ package org.jxkj.utils;
/*    */ 
/*    */ import java.io.ByteArrayInputStream;
/*    */ import java.io.InputStream;
/*    */ import java.util.ArrayList;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.regex.Matcher;
/*    */ import java.util.regex.Pattern;

/*    */ public class PointFormulaKit
/*    */ {
/*    */   public static List<String> getSubUtil(String soap, String rgex) {
/* 27 */     List<String> list = new ArrayList<>();
/* 28 */     Pattern pattern = Pattern.compile(rgex);
/* 29 */     Matcher m = pattern.matcher(soap);
/* 30 */     while (m.find()) {
/* 31 */       int i = 1;
/* 32 */       list.add(m.group(i));
/* 33 */       i++;
/*    */     } 
/* 35 */     return list;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public static InputStream getStrToStream(String sInputString) {
/* 45 */     if (sInputString != null && !sInputString.trim().equals("")) {
/*    */       try {
/* 47 */         ByteArrayInputStream tInputStringStream = new ByteArrayInputStream(sInputString.getBytes());
/* 48 */         return tInputStringStream;
/* 49 */       } catch (Exception ex) {
/* 50 */         ex.printStackTrace();
/*    */       } 
/*    */     }
/* 53 */     return null;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public static String getSqlString(List<String> str) {
/* 63 */     StringBuffer sb = new StringBuffer();
/* 64 */     for (int i = 0; i < str.size(); i++) {
/* 65 */       sb.append("'").append(str.get(i)).append("'").append(",");
/*    */     }
/* 67 */     return sb.toString().substring(0, sb.length() - 1);
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public static double getPointValue(String formula, Map<String, Double> data) throws Exception {
/* 79 */     Map<String, Object> ctx = new HashMap<>();
/* 80 */     ctx.put("scene", "组合测点计算");
/* 81 */     InputStream is = getStrToStream(formula);
/* 82 */     ScriptTool sc = new ScriptTool(is, ctx);
/* 83 */     Object result = sc.execute(new Object[] { data });
/* 84 */     return ((result == null) ? null : Double.valueOf(Double.parseDouble(result.toString()))).doubleValue();
/*    */   }
/*    */   
/*    */   public static String getPointValue(Map<String, Double> data, ScriptTool sc) throws Exception {
/* 88 */     Object result = sc.execute(new Object[] { data });
/* 89 */     return (result == null) ? null : result.toString();
/*    */   }
/*    */ }


/* Location:              C:\Users\xqh\Desktop\gzbDataAnalyse-1.0-SNAPSHOT-jar-with-dependencies.jar!\org\jxk\\utils\PointFormulaKit.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */